package com.bdqn.bookshop.common;

/**
 * @author : 罗若然[LUO_RUO_RAN]
 * @date : 2020-07-24 11:04
 * 是否打折
 **/
public enum  BookDiscountEnum {

    DEFAULT(0, "ERROR"),
    DISCOUNT_FALSE(1, "不打折"),
    DISCOUNT_TRUE(2, "打折");

    private Integer discount;
    private String name;


    BookDiscountEnum(int discount, String name) {
        this.discount = discount;
        this.name = name;
    }

    public static BookDiscountEnum getBookDiscount(int discount) {
        for (BookDiscountEnum userDiscountEnum : BookDiscountEnum.values()) {
            if (userDiscountEnum.getDiscount() == discount) {
                return userDiscountEnum;
            }
        }
        return DEFAULT;
    }



    public Integer getDiscount() {
        return discount;
    }

    public void setDiscount(Integer discount) {
        this.discount = discount;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
